home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / BI_VARS.C < prev    next >
C/C++ Source or Header  |  1991-10-05  |  2KB  |  102 lines

  1.  
  2. /********************************************
  3. bi_vars.c
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13. /* $Log:    bi_vars.c,v $
  14.  * Revision 3.4.1.1  91/09/14  17:22:45  brennan
  15.  * VERSION 1.0
  16.  * 
  17.  * Revision 3.4  91/08/13  06:50:52  brennan
  18.  * VERSION .9994
  19.  * 
  20.  * Revision 3.3  91/06/29  09:46:53  brennan
  21.  * Only track NR if needed
  22.  * 
  23.  * Revision 3.2  91/06/28  04:16:08  brennan
  24.  * VERSION 0.999
  25.  * 
  26.  * Revision 3.1  91/06/07  10:26:56  brennan
  27.  * VERSION 0.995
  28.  * 
  29.  * Revision 2.2  91/05/29  14:24:51  brennan
  30.  * -V option for version
  31.  * 
  32.  * Revision 2.1  91/04/08  08:22:22  brennan
  33.  * VERSION 0.97
  34.  * 
  35. */
  36.  
  37.  
  38. /* bi_vars.c */
  39.  
  40. #include "mawk.h"
  41. #include "symtype.h"
  42. #include "bi_vars.h"
  43. #include "field.h"
  44. #include "init.h"
  45. #include "memory.h"
  46.  
  47. /* the builtin variables */
  48. CELL  bi_vars[NUM_BI_VAR] ;
  49.  
  50. /* the order here must match the order in bi_vars.h */
  51.  
  52. static char *bi_var_names[NUM_BI_VAR] = {
  53. "NR" ,
  54. "FNR" ,
  55. "ARGC" ,
  56. "FILENAME" ,
  57. "OFS" ,
  58. "ORS" ,
  59. "RLENGTH" ,
  60. "RSTART" ,
  61. "SUBSEP"
  62. } ;
  63.  
  64. /* insert the builtin vars in the hash table */
  65.  
  66. void  bi_vars_init()
  67. { register int i ;
  68.   register SYMTAB *s ;
  69.  
  70.   
  71.   for ( i = 0 ; i < NUM_BI_VAR ; i++ )
  72.   { s = insert( bi_var_names[i] ) ;
  73.     s->type = i <= 1 ? ST_NR : ST_VAR ; 
  74.     s->stval.cp = bi_vars + i ;
  75.     /* bi_vars[i].type = 0 which is C_NOINIT */
  76.   }
  77.  
  78.   /* set defaults */
  79.  
  80.   bi_vars[FILENAME].type = C_STRING ;
  81.   bi_vars[FILENAME].ptr = (PTR) new_STRING( "" ) ; 
  82.  
  83.   bi_vars[ OFS ].type = C_STRING ;
  84.   bi_vars[OFS].ptr = (PTR) new_STRING( " " ) ;
  85.   
  86.   bi_vars[ ORS ].type = C_STRING ;
  87.   bi_vars[ORS].ptr = (PTR) new_STRING( "\n" ) ;
  88.  
  89.   bi_vars[ SUBSEP ].type = C_STRING ;
  90.   bi_vars[SUBSEP].ptr =  (PTR) new_STRING( "\034" ) ;
  91.  
  92.   bi_vars[NR].type = bi_vars[FNR].type = C_DOUBLE ;
  93.   /* dval is already 0.0 */
  94.  
  95.   cell_zero.type = C_DOUBLE ;
  96.   cell_one.type = C_DOUBLE ;
  97.   cell_one.dval = 1.0 ;
  98. }
  99.  
  100. CELL cell_zero ;
  101. CELL cell_one ;
  102.